using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Data;

namespace RaidLog.Engine
{
    public class WowInstallation
    {
        private static readonly string COMBAT_LOG_PATH = @"Logs\WoWCombatLog.txt";
        private static readonly string CHAT_LOG_PATH = @"Logs\WoWChatLog.txt";

        WowLogFile _CombatLog;
        WowLogFile _ChatLog;

        public WowInstallation(string path)
        {
            if (!File.Exists(Path.Combine(path, COMBAT_LOG_PATH)))
            {
                throw new ApplicationException("Not Found: " + Path.Combine(path, COMBAT_LOG_PATH));
            }
            if (!File.Exists(Path.Combine(path, CHAT_LOG_PATH)))
            {
                throw new ApplicationException("Not Found: " + Path.Combine(path, CHAT_LOG_PATH));
            }
            _CombatLog = new WowLogFile(Path.Combine(path, COMBAT_LOG_PATH));
            _ChatLog = new WowLogFile(Path.Combine(path, CHAT_LOG_PATH));
        }

        public WowLogFile CombatLog
        {
            get
            {
                return _CombatLog;
            }
        }

        public WowLogFile ChatLog
        {
            get
            {
                return _ChatLog;
            }
        }

        public IEnumerable<string[]> GetLineSets(DateTime dateTimeStart, DateTime dateTimeEnd, int lineSetSize)
        {
            foreach (string[] lines in CombatLog.GetLineSets(dateTimeStart, dateTimeEnd, lineSetSize))
            {
                yield return lines;
            }
            foreach (string[] lines in ChatLog.GetLineSets(dateTimeStart, dateTimeEnd, lineSetSize))
            {
                yield return lines;
            }
        }
    }
}
